package observable.threadpool

import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.ThreadPoolExecutor

class ThreadPoolFactory {
    companion object {
        // 下流使用的线程
        private val default: ExecutorService by lazy { Executors.newSingleThreadExecutor() }
        // 上流使用的线程
        private val newThread: ExecutorService by lazy { Executors.newCachedThreadPool() }

        fun getDefaultPool(): ExecutorService {
            return default
        }

        fun getNewThreadPool(): ExecutorService {
            return newThread
        }
    }
}